﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoleDispose.aspx.cs" Inherits="HHWeb.SystemManage.Roles.RoleDispose" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title><%=Command %>角色管理</title>
<style type="text/css">
ul.ztree {margin-top: 10px;margin-bottom: 10px;border: 1px solid #617775;background: #f0f6e4;width:200px;height:280px;overflow-y:scroll;overflow-x:auto;}
</style>
<link href="../../Css/backCommon.css" rel="stylesheet" type="text/css" />
<link href="../../Css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="30px" background="../../images/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12px" height="30px"><img src="../../images/tab_03.gif" width="12px" height="30px"/></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="46%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><div align="center"><img src="../../images/tb.gif" width="16px" height="16px" /></div></td>
                <td width="95%" class="STYLE1"><span class="STYLE3">你当前的位置</span>：[业务中心]-[我的邮件]</td>
              </tr>
            </table></td>
            <td width="54%">&nbsp;</td>
          </tr>
        </table></td>
        <td width="16px"><img src="../../images/tab_07.gif" width="16px" height="30px" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="8px" background="../../images/tab_12.gif">&nbsp;</td>
        <td>
    <%--Submit数据区头--%>
    <table id="EditArea" border="1" cellpadding="1" cellspacing="1" width="100%">
    <tr><td><span>角色名称：</span></td><td><input type="text" id="RoleName" name="RoleName" class="TextCommon"  value="<%=RoleName %>"/></td></tr>
    <tr><td><span>页面权限：</span></td><td>
    <div class="zTreeDemoBackground left">
     <ul id="tree" class="ztree"></ul>
	</div>
    <input type="hidden" id="PagePowerParentIDArr" name="PagePowerParentIDArr" value=""/>
    <input type="hidden" id="PagePowerIDArr" name="PagePowerIDArr" value=""/>
    </td></tr>
    <tr><td><span>状态：</span></td><td>
    <select id="OpenStatus" name="OpenStatus" class="Common">
    <option value="1" <%=OpenStatus=="1"?"selected=selected":"" %>>启用 </option>
    <option value="0" <%=OpenStatus=="0"?"selected=selected":"" %>>禁用 </option>
    </select>
    </td></tr>
    <tr><td><span>功能说明：</span></td><td><textarea id="FunctionIntro" 
            name="FunctionIntro" class="TextCommon" style="height:80px; width: 520px"><%=FunctionIntro%></textarea></td></tr>
    <tr><td><span>创建人：</span></td><td><input type="text" id="Creater" name="Creater" class="TextCommon" readonly="readonly"  value="<%=Creater%>"/></td></tr>
    <tr><td><span>创建时间：</span></td><td><input type="text" id="CreateTime" name="CreateTime"  class="TextCommon" readonly="readonly" value="<%=CreateTime %>"/></td></tr>
    <tr><td>&nbsp;</td><td><input type="button"  id="BTSubmit" name="BTSubmit" class="Common" value="确定"/></td></tr>
    </table>
    <%--Submit数据区尾--%>
        </td>
        <td width="8px" background="../../images/tab_15.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="35px" background="../../images/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12px" height="35px"><img src="../../images/tab_18.gif" width="12px" height="35px" /></td>
        <td>
        <%--分页区头--%>
        <%--分页去尾--%>
        </td>
        <td width="16px"><img src="../../images/tab_20.gif" width="16px" height="35px" /></td>
      </tr>
    </table></td>
  </tr>
</table>
    </form>
    <script type="text/javascript" src="../../Scripts/jquery-1.4.1.min.js"></script>
    <script src="../../JS/jquery.ztree.core-3.0.js" type="text/javascript"></script>
    <script src="../../JS/jquery.ztree.excheck-3.0.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        $(function () {
            var setting = {
                check: { enable: true },
                data: { simpleData: { enable: true} },
                callback: { beforeClick: beforeClick, onClick: onClick, onCheck: onCheck }
            };
            //绑定树形控件值
            $.getJSON("../../Handler/TreePagePower.ashx", { rd: Math.random() }, function (data) {
                var zNodes = "";
                $.each(data.TreeJson, function (i, item) {
                    if (data.TreeJson.length - 1 == i) {
                        zNodes += "{id:" + item.ID + "," + "pId:" + item.ParentID + "," + "name:'" + item.PagePowerName + "'" + "," + "checked:false" + "," + "open: false}";
                    }
                    else {
                        zNodes += "{id:" + item.ID + "," + "pId:" + item.ParentID + "," + "name:'" + item.PagePowerName + "'" + "," + "checked:false" + "," + "open: false}" + ",";
                    }
                })
                zNodes = "[" + zNodes + "]";
                $.fn.zTree.init($("#tree"), setting, eval("(" + zNodes + ")"));
            });
            //确定时间
            $("#BTSubmit").click(function () {
                if ($("#RoleName").val() == "" || $("#RoleName").val() == null) {
                    alert('角色名称不能为空！');
                    $("#RoleName").focus();
                    return;
                }
                if ($("#PagePowerIDArr").val() == "" || $("#PagePowerIDArr").val() == null || $("#PagePowerParentIDArr").val() == "" || $("#PagePowerParentIDArr").val() == null) {
                    alert('请给角色分配权限！');
                    return;
                }
                alert($("#PagePowerIDArr").val());
                $("#form1").attr("method", "POST");
                $("#form1").submit();
            })
            $("#EditArea tr").hover(function () {
                $(this).css("background-color", "#ecf8ff");
            }, function () {
                $(this).css("background-color", "");
            })
        })
        function beforeClick(treeId, treeNode) {
            //           // alert("ID:" + treeNode.id + "|" + "父级ID：" + treeNode.pId + "|" + "名称：" + treeNode.name);
            //            var check = (treeNode && !treeNode.isParent);
            //            if (!check) alert("请选择部门...");
            //            return check;
            //$("#Lists").load("OrgList.aspx", { ID: treeNode.id }, function () {});
        }
        function onClick(e, treeId, treeNode) {
            //alert("ID:" + treeNode.id + "|" + "父级ID：" + treeNode.pId + "|" + "名称：" + treeNode.name);
            //window.location.href = "http://www.baidu.com";
            //$("#Lists").load("OrgList.aspx", { ID: treeNode.id }, function () {});
        }
        var PagePowerIDArr="";
        function onCheck(e, treeId, treeNode) {
            //var treeObj = $.fn.zTree.getZTreeObj("tree");
            //treeObj.checkAllNodes(true);
            if (treeNode.isParent) {
                //判断是不是父级节点
                return;
            }
            if (treeNode.checked) {
                if (PagePowerIDArr == "" || PagePowerIDArr == null)
                    PagePowerIDArr = treeNode.id;
                else
                    PagePowerIDArr +=","+treeNode.id.toString() ;
            }
            else {
//                var arr = "";
//                if (PagePowerIDArr.indexOf(",") > 0) {
//                    arr = PagePowerIDArr.split(",");
//                    PagePowerIDArr = "";
//                    for (var i = 0; i < arr.length; i++) {
//                        if (arr[i] != treeNode.id) {
//                            if (PagePowerIDArr == "" || PagePowerIDArr == null)
//                                PagePowerIDArr = arr[i];
//                            else
//                                PagePowerIDArr += "," + arr[i];
//                        }
//                    }
//                }
//                else {
//                    PagePowerIDArr = "";
//                }
            }
            var treeObj = $.fn.zTree.getZTreeObj("tree");
            var nodes = treeObj.getNodes();
            if (nodes.length > 0) {
                treeObj.selectNode(nodes[0]);
            }

            $("#PagePowerIDArr").val(PagePowerIDArr);
            //alert("ID:" + treeNode.id + "|" + "父级ID：" + treeNode.pId + "|" + "名称：" + treeNode.name);
        }
       </script>
</body>
</html>
